cap log close
snapshot erase _all
clear all

*===========================*
*	Set Globals				*
*===========================*

	global filenum 03
	global filename "gen_analysis"

*===========================*
*	Set Locals				*
*===========================*

	local m_list "12 1 2 3 4 5 6"

*===========================*
*	Load In ASEC Data		*
*===========================*
	log using "${log_path}/${filenum}_${filename}.smcl", replace

	use "${data_path}/asec_2018_2020.dta" , clear
	
*=======================*
*	Setup for DDD		*
*=======================*

		drop year	// this year variable will mis-assign December for the purposes of our analysis
	
	// set firm size definition
		gen firmSize=firmsize_asec
		gen under500=under500_asec

	// set sample restrictions
	
		keep if age>=21 & age<=59
	
		keep if under500!=.
		keep if tw_binary_10ly!=.

	// gen any other control variables
	
		gen age2=age^2

		
	// Gender + Parent Interaction Subgroups
		gen gender_parent = .
			replace gender_parent = 1 if female==1 & childUnder12 ==1
			replace gender_parent = 2 if female==0 & childUnder12 ==1
			replace gender_parent = 3 if female==1 & childUnder12 ==0
			replace gender_parent = 4 if female==0 & childUnder12 ==0
			
		label define gend_x_kids 1 "Women w Kids" 2 "Men w Kids" 3 "Women no Kids" 4 "Men no Kids"
		label values gender_parent gend_x_kids
	
	// Industry 2-digit Fixed Effects
		tostring ind1990, gen(ind_string)
		gen ind_2digit = substr(ind_string, 1,2)			
		
*===============*
* Make DD Vars	*
*===============*
	
	gen y2020=(asec_year==2020)	
	
	gen small=(under500==1)
		replace small=0 if private==0 
	
	
	gen small_x_y2020=small*y2020
	
	gen m4to6 = (month>=4)
	
	gen m4to6_x_small = m4to6 * small
	gen m4to6_x_y2020 = m4to6 * y2020
	gen m4to6_x_small_y2020 = m4to6 * small * y2020
		
	** Month Dummies
		foreach i in `m_list'{
			gen m`i'=(month==`i')
		}
		
	** Month by 2020	
		foreach i in `m_list'{
			gen m`i'_x_y2020=(m`i' * y2020)
		}
	
	** Month by Treat
	
		foreach i in 12 1 2 3 4 5 6{
			gen m`i'_x_small=(m`i'*small)
		}

	** Month by Treat by Year
		foreach i in 12 1 2 3 4 5 6{
			gen m`i'_x_small_y2020=(m`i'*small*y2020)
		}
		
	drop  m2*
	
	

*=======================*
* Save Analysis File	*
*=======================*

	save "${data_path}/analysis_file.dta", replace
